<?php echo $this->render('/public/header'); ?>
    <script src="https://cdn.bootcss.com/element-ui/2.0.9/index.js"></script>
    <link href="https://cdn.bootcss.com/element-ui/2.0.9/theme-chalk/index.css" rel="stylesheet">
    <div id="main" class="col-xs-12">
        数据解释//销售金额--订单数量--客户人数(统计的是当月订单的收款)
        <br/>
        <br/>
        <el-date-picker
                v-model="year"
                align="right"
                type="year"
                value-format="yyyy"
                @change="handlerChange"
                placeholder="选择年">
        </el-date-picker>
        <br/>
        <br/>
        <table id="table" class="table table-borderd">
            <thead>
            <tr>
                <th>业务员</th>
                <?php $month = [];
                $i = ($year >= date('Y')) ? date('m') : 12;
                for (; $i >= 1; $i--) : ?>
                    <th>
                        <?php
                        $m = $year . '-' . str_pad($i, 2, 0, STR_PAD_LEFT);
                        $month[] = $m;
                        echo $m;
                        ?>
                    </th>
                <?php endfor; ?>
                <th>统计</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($list as $k => $v): ?>
                <tr>
                    <td><?php echo $v['name']; ?></td>
                    <?php foreach ($month as $v2): ?>
                        <td style="text-align: right">
                            <?php if (isset($v[$v2])) : ?>
                                <a href="/table/month-invoice?service_name=<?php echo $k; ?>&begin_time=<?php echo $v2; ?>-01&end_time=<?php echo $v2; ?>-31&property_p=17">
                                    <?php echo $v[$v2]['total']; ?>
                                    <span class='badge'><?php echo $v[$v2]['num'] ?></span>
                                </a>
                            <?php else: ?>
                                0
                            <?php endif; ?>
                        </td>
                    <?php endforeach; ?>
                    <td style="text-align:right">
                        <?php echo $v['total']; ?>
                        <span class="badge"><?php echo $v['num']; ?></span>
                    </td>
                </tr>
            <?php endforeach; ?>
            <tr>
                <td>统计</td>
                <?php foreach ($month as $k => $v) : ?>
                    <td style="text-align: right">
                        <?php echo isset($total[$v]) ? $total[$v]['money'] : 0; ?>
                        <span class="badge">
            <?php echo isset($total[$v]) ? $total[$v]['num'] : 0; ?></span>
                    </td>
                <?php endforeach; ?>
                <td style="text-align: right">
                    <?php echo $total['total']['money']; ?>
                    <span class="badge">
            <?php echo $total['total']['num']; ?></span>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <script type="text/javascript">
        new Vue({
            el: "#main",
            data: {
                year: '<?php echo $year;?>',
            },
            methods: {
                handlerChange: function (v) {
                    window.location.href = "/table/sell_count?year=" + v;
                }
            }
        })
    </script>
<?php echo $this->render('/public/footer'); ?>